import math

def circular_cone(data:dict):
    """
    计算圆锥体，输入一个字典，返回一个字典
    :param data:字典
    {
    r:半径
    h:高度
    }
    
    :return res:字典
    {
    "Slope_height":斜面高
    "Surface_area_of_curved_surface":曲面表面积
    "Cone_surface_area":圆锥表面积
    "Cone_volume":圆锥体积
    }
    """
    if "r" in data and "h" in data:
        r = data["r"]
        h = data["h"]
        Slope_height = math.sqrt(r * r + h * h)
        Surface_area_of_curved_surface = math.pi * r * Slope_height
        Cone_surface_area = math.pi * r * r + math.pi * r * Slope_height
        Cone_volume = math.pi * r * r * h / 3
    else:
        return {
            "error":"不能为空！"
        }
    return {
        'Slope_height':Slope_height,
        "Surface_area_of_curved_surface" : Surface_area_of_curved_surface,
        "Cone_surface_area" : Cone_surface_area,
        "Cone_volume" : Cone_volume
    }


def test():
    """
    测试函数
    :return:
    """
    data = {
        "r" : 2,
        "h" : 3
        }
    res = circular_cone(data)
    print(res)


test()
